//
//  BaseNavTransparencyViewController.swift
//  app
//
//  Created by g1 on 2023/9/5.
//

import UIKit

class BaseNavTransparencyViewController: BaseViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        view.backgroundColor = .app_viewBackgroundColor
    }
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        
        navIsHidden = false
        
        configNavi()

        if #available(iOS 13.0, *) {
            let appearance = UINavigationBarAppearance()
            appearance.configureWithOpaqueBackground()
            appearance.backgroundColor = .app_viewBackgroundColor
            appearance.shadowColor = .clear
            navigationController?.navigationBar.standardAppearance = appearance
            navigationController?.navigationBar.scrollEdgeAppearance = appearance
        } else {
            // Fallback on earlier versions
        }

    }
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        navIsHidden = true
    }
    
    func configNavi() {
        
        let leftItemBackView = UIView(frame: CGRect(x: 0, y: 0, width: 18, height: 18))
        let leftItemBtn = UIButton(frame: leftItemBackView.bounds)
        leftItemBtn.addTarget(self, action: #selector(backAction), for: .touchUpInside)
        leftItemBtn.setImage(UIImage(named: self.presentingViewController == nil ? "navBack":"close_x"), for: .normal)
        leftItemBackView.addSubview(leftItemBtn)
        navigationItem.leftBarButtonItem = UIBarButtonItem(customView: leftItemBackView)
        
    }

}
